#include "queentable.h"
#include "ui_queentable.h"
#include "boarditem.h"

QueenTable::QueenTable(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::QueenTable)
{
    ui->setupUi(this);
	this->view = new QueenView(this);
	ui->gridLayout->addWidget(this->view);
	this->setMaximumSize(560,500);
	this->setMinimumSize(560,500);
	this->drawBoard();
}

QueenTable::~QueenTable()
{
	delete view;
    delete ui;
}
void QueenTable::resizeEvent(QResizeEvent *event)
{
	this->ui->labelSizeW->setText(QString::number(event->size().width()));
	this->ui->labelSizeH->setText(QString::number(event->size().height()));
}
void QueenTable::drawBoard()
{
	int x = 0;
	int y = 0;
	ColorBoardItem colorItem = White;
	for(int i = 0 ; i < 8 ; i++)
	{
		for(int j = 0 ; j < 8 ; j++)
		{
			this->view->scene()->addBoardItem(new BoardItem(QRect(x,y,50,50),colorItem));
			x+=50;
			colorItem = nextColorBoardItem(colorItem);
		}
		colorItem = nextColorBoardItem(colorItem);
		x = 0;
		y += 50;
	}
	this->view->scene()->drawBoard();
}
void QueenTable::updateBoard(QGenericMatrix<8,8,int> & matrix)
{
    for(int i = 0 ; i < 8 ; i++)
    {
	for(int j = 0 ; j < 8 ; j++)
	{
	    if(matrix(i,j) == 1)
	    {

	    }
	}
    }
}
